package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import entity.Dept;

public class DeptDao {
	public List<Dept> selectAllDept(Connection conn) throws SQLException{
		List<Dept> list = new ArrayList<Dept>();
		String sql = "select * from dept";
		PreparedStatement pre = conn.prepareStatement(sql);
		ResultSet set = pre.executeQuery();
		while(set.next()) {
			Dept dept = new Dept();
			dept.setId(set.getInt("id"));
			dept.setName(set.getString("name"));
			list.add(dept);
		}
		pre.close();
		set.close();
		return list;
	}
}
